class BD_Fists extends BlackDeathWeapon;

var Actor LastHitPawn;//Stores last thing the sword hit.
var float MomentumScale;//Scalar for how much momentum to put onto an enemy when attacked.
var name FistSocket;//name of the socket to track
	
	function Tick( FLOAT DeltaSeconds )
	{
		local vector Loc;
		local Pawn P;
		Super.Tick( DeltaSeconds );
		
		if(IsFiring() && Instigator != none)
		{
			Instigator.Mesh.GetSocketWorldLocationAndRotation(FistSocket, Loc);
			ForEach OverlappingActors(class'Pawn', P, 10, Loc)
			{
				if ((BlackDeathPawn(P) != None) && P != Instigator)
				{
					if(P != LastHitPawn)//if we hit a pawn and its not one we already hit
					{
						`log("Falcon punching"@P);
						//`log("Last hit"@LastHitPawn);
						doAttack(P, Loc);
						LastHitPawn = P;
					}
				}
			}
		}
	}
	
	simulated function doAttack(Pawn AttackedPawn, Vector HitLocation)//Do the actual hit to the thing
	{
		local vector X, Y, Z, Momentum;
		GetAxes(Instigator.rotation, X, Y, Z);
		Momentum = MomentumScale * X /*+ MomentumScale * Y + MomentumScale * Z*/;//Find the player's rotation in vector form and multiple it by the force of the attack
		if(currentfiremode == 0)
		{
			AttackedPawn.TakeDamage(WeaponDamage, Instigator.Controller, HitLocation, Momentum, class'DmgType_Crushed');
		}
		if(currentfiremode == 1)
		{
			AttackedPawn.TakeDamage(HeavyWeaponDamage, Instigator.Controller, HitLocation, Momentum, class'DmgType_Crushed');
		}
	}

	simulated function bool HasAnyAmmo()
	{
		return true;//Weapon always has ammo
	}

	function ConsumeAmmo( byte FireModeNum )
	{
		//Melee weapons do not consume ammo
	}
	
	function int AddAmmo(int Amount)
	{
		//Melee weapons cannot get ammo
	}
	
	simulated state WeaponFiring
	{
		simulated function RefireCheckTimer()
		{
			Super.RefireCheckTimer();
			LastHitPawn = None;
		}
	}

	simulated function CustomFire()
	{
		local BlackDeathPawn BDP;
		BDP = BlackDeathPawn(Instigator);
		`log("custom fire called with firemode: "@currentfiremode);
		if(BDP != none)
		{
			if(currentFireMode == 0)
			{
				LightSwing();
			}
			if(currentfireMode == 1)
			{
				HeavySwing();
			}
		}
	}
	
	simulated function LightSwing()
	{
		if(BlackDeathPawn(instigator) != none)
			{
				BlackDeathPawn(instigator).LightSwing(/*We need to have a varible to record item classes*/);
			}
	}
	
	simulated function HeavySwing()
	{
		if(BlackDeathPawn(instigator) != none)
		{
			BlackDeathPawn(instigator).HeavySwing(/*We need to have a varible to record item classes*/);
		}
	}
	

DefaultProperties
{
	
	WeaponDamage = 10; //How much damage the wepon does
	HeavyWeaponDamage = 20;//How much damage the heavy fire mode does
	
	WeaponRange = 55//The weapon's range. Used for AI and maybe ranged weapons.
	
	FiringStatesArray(0)=WeaponFiring
	FiringStatesArray(1)=WeaponFiring
	WeaponFireTypes(0)=EWFT_Custom
	WeaponFireTypes(1)=EWFT_Custom
	
	WeaponProjectiles(0)=none
	
	EquipTime=+0.33
	PutDownTime=+0.33
	
	FireInterval(0)=1.0
	FireInterval(1)=1.0
	
	Spread(0)=0.0
	Spread(1)=0.0

	AIRating=1.0
	
	WeaponEquipAnim=WeaponEquip
	FireAnim = VM_Stab
	
	FistSocket = WeaponPoint
}